
#include<bits/stdc++.h>
using namespace std;


int main()
{
    vector<string>arr;
    string cmd;
    while (cin>>cmd)
    {
        if (cmd == "insert")
        {
            int pos; string name;
            cin >> pos >> name;
            pos--;//转化下标
            arr.insert(arr.begin() + pos, name);//插入
        }
        else if (cmd == "delete")
        {
            string name; cin >> name;
            auto  pos = find(arr.begin(), arr.end(), name);
            arr.erase(pos);
        }
        else if (cmd == "show")
        {
            for (auto x : arr)
                cout << x << " ";
            cout << endl;
        }
        else if (cmd == "search")
        {
            string name; cin >> name;
            auto  pos = find(arr.begin(), arr.end(), name);
            cout << pos - arr.begin() + 1 << endl;
        }
    }
    return 0;
}
